unsigned int handle;
unsigned int evtchn, irq;
- /* What is the status of our connection to the remote backend? */
-#define BEST_CLOSED 0
-#define BEST_DISCONNECTED 1
-#define BEST_CONNECTED 2
- unsigned int backend_state;
-
/* Receive-ring batched refills. */
#define RX_MIN_TARGET 8
#define RX_DFL_MIN_TARGET 64
return id;
}
-#ifdef DEBUG
-static const char *be_state_name[] = {
- [BEST_CLOSED] = "closed",
- [BEST_DISCONNECTED] = "disconnected",
- [BEST_CONNECTED] = "connected",
-};
-#endif
-
#define DPRINTK(fmt, args...) pr_debug("netfront (%s:%d) " fmt, \
__FUNCTION__, __LINE__, ##args)
#define IPRINTK(fmt, args...) \
}
memset(txs, 0, PAGE_SIZE);
memset(rxs, 0, PAGE_SIZE);
- info->backend_state = BEST_DISCONNECTED;
SHARED_RING_INIT(txs);
FRONT_RING_INIT(&info->tx, txs, PAGE_SIZE);
struct netfront_info *np = netdev_priv(dev);
struct sk_buff *skb;
- if (np->backend_state != BEST_CONNECTED)
+ if (unlikely(!netif_carrier_ok(dev)))
return;
do {
struct xen_memory_reservation reservation;
grant_ref_t ref;
- if (unlikely(np->backend_state != BEST_CONNECTED))
+ if (unlikely(!netif_carrier_ok(dev)))
return;
/*
spin_lock_irq(&np->tx_lock);
- if (np->backend_state != BEST_CONNECTED) {
+ if (unlikely(!netif_carrier_ok(dev))) {
spin_unlock_irq(&np->tx_lock);
goto drop;
}
spin_lock(&np->rx_lock);
- if (np->backend_state != BEST_CONNECTED) {
+ if (unlikely(!netif_carrier_ok(dev))) {
spin_unlock(&np->rx_lock);
return 0;
}
* domain a kick because we've probably just requeued some
* packets.
*/
- np->backend_state = BEST_CONNECTED;
+ netif_carrier_on(dev);
notify_remote_via_irq(np->irq);
network_tx_buf_gc(dev);
if (np) {
IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n",
np->handle,
- be_state_name[np->backend_state],
+ netif_carrier_ok(np->netdev) ? "on" : "off",
netif_running(np->netdev) ? "open" : "closed",
np->evtchn,
np->tx,
}
np = netdev_priv(netdev);
- np->backend_state = BEST_CLOSED;
np->handle = handle;
np->xbdev = dev;
+ netif_carrier_off(netdev);
+
spin_lock_init(&np->tx_lock);
spin_lock_init(&np->rx_lock);
/* Stop old i/f to prevent errors whilst we rebuild the state. */
spin_lock_irq(&info->tx_lock);
spin_lock(&info->rx_lock);
- info->backend_state = BEST_DISCONNECTED;
+ netif_carrier_off(info->netdev);
spin_unlock(&info->rx_lock);
spin_unlock_irq(&info->tx_lock);